import {Pipe, PipeTransform} from '@angular/core';
import {DomSanitizer} from '@angular/platform-browser';

@Pipe({
    name: 'safe'
})
/**
 * @author csw
 * @description:解析iframe网页嵌入-safe安全管道机制将url转换为angular中iframe可以识别的安全url链接
 * @date 2021-02-04 14:17:23
 */
export class SafePipe implements PipeTransform {
    constructor(private sanitizer: DomSanitizer) {
    }

    transform(url: any): any {
        return (this.sanitizer.bypassSecurityTrustResourceUrl(url) || this.sanitizer.bypassSecurityTrustUrl(url));
    }

}
